﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

namespace Base.Data.Migrations
{
    public partial class base_label : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<string>(
                name: "label_base_label_id",
                table: "t_menu",
                type: "character varying(50)",
                maxLength: 50,
                nullable: true);

            migrationBuilder.CreateTable(
                name: "t_base_label",
                columns: table => new
                {
                    id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
                    type = table.Column<int>(type: "integer", nullable: false),
                    api_key = table.Column<string>(type: "character varying(60)", maxLength: 60, nullable: true),
                    label_key = table.Column<string>(type: "character varying(400)", maxLength: 400, nullable: true),
                    other_label_key = table.Column<string>(type: "character varying(600)", maxLength: 600, nullable: true),
                    remark = table.Column<string>(type: "character varying(400)", maxLength: 400, nullable: true),
                    org_id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
                    create_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    modify_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    is_deleted = table.Column<bool>(type: "boolean", nullable: false),
                    row_version = table.Column<int>(type: "integer", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_t_base_label", x => x.id);
                });

            migrationBuilder.CreateTable(
                name: "t_base_label_detail",
                columns: table => new
                {
                    id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
                    base_label_id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
                    lang = table.Column<string>(type: "character varying(60)", maxLength: 60, nullable: true),
                    label = table.Column<string>(type: "character varying(2000)", maxLength: 2000, nullable: true),
                    is_edit_by_menu = table.Column<bool>(type: "boolean", nullable: false),
                    org_id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
                    create_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    modify_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    is_deleted = table.Column<bool>(type: "boolean", nullable: false),
                    row_version = table.Column<int>(type: "integer", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_t_base_label_detail", x => x.id);
                });

            migrationBuilder.CreateIndex(
                name: "IX_t_base_label_api_key",
                table: "t_base_label",
                column: "api_key");

            migrationBuilder.CreateIndex(
                name: "IX_t_base_label_create_time",
                table: "t_base_label",
                column: "create_time");

            migrationBuilder.CreateIndex(
                name: "IX_t_base_label_label_key",
                table: "t_base_label",
                column: "label_key");

            migrationBuilder.CreateIndex(
                name: "IX_t_base_label_detail_create_time",
                table: "t_base_label_detail",
                column: "create_time");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "t_base_label");

            migrationBuilder.DropTable(
                name: "t_base_label_detail");

            migrationBuilder.DropColumn(
                name: "label_base_label_id",
                table: "t_menu");
        }
    }
}
